package Com.javaserver.dao;

import Com.javaserver.bean.departmentinquire;

import Com.javaserver.utils.DB;

import java.util.List;

public class departmentserver {

    //部门添加
    public departmentinquire departA(departmentinquire deadd) {
        int i = DB.executeUpdate("insert into department (D_name,D_time,D_number,D_note,D_operation) values( ?, ?, ?, ?, ?)", deadd.getD_name()
                , deadd.getD_time(), deadd.getD_number(), deadd.getD_note(), deadd.getD_operation());
        if (i == -1) {
            return null;
        }
        return deadd;
    }

    //显示部门列表
    public List queryALl(Integer page) {
        List list = DB.executeQuery("select * from department limit ?, 10", (page - 1) * 10);
        return list;
    }

    //删除方法
    public boolean dele(departmentinquire depar) {
        String sql = "delete from department where D_ID=?";//执行sql语句
        int i = DB.executeUpdate(sql, depar.getD_ID());//声明一个变量获取sql,以及数据库表id
        return i > 0; //如果受影响的行数大于1就表示成功删除
    }

    //更新方法  这个是没调用的更新方法
    public boolean upadet(departmentinquire updetpar) {
        String sql = "updata department set name where id?";
        int i = DB.executeUpdate(sql, updetpar.getD_ID());
        return i > 0;
    }
}
